﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Ue.Core.FileSystems;

namespace Ue.Framework.Tests.Core.FileSystems
{
    [TestClass]
    public class IFolderExtensionsTests
    {
        private IFolder folder;
        private IFolderRoot folderRoot;

        [TestInitialize]
        public void Initial()
        {
            this.folderRoot = new FolderRoot("Directory1");
            this.folder = new Folder(this.folderRoot);

            Directory.CreateDirectory("Directory1");
        }

        [TestMethod]
        [DeploymentItem("Core/FileSystems/MockFiles", "Directory1/MockFiles")]
        public void CombineToPhysicalPathCombineToAppPath()
        {
            Assert.AreEqual(this.folderRoot.RootPhysicalPath, this.folder.CombineToPhysicalPath(""));

            Assert.AreEqual(this.folderRoot.RootPhysicalPath + "\\ChildDirectory1", this.folder.CombineToPhysicalPath("ChildDirectory1"));

            Assert.AreEqual(this.folderRoot.RootPhysicalPath + "\\ChildDirectory1", this.folder.CombineToPhysicalPath("/ChildDirectory1"));

            Assert.AreEqual(this.folderRoot.RootPhysicalPath + "\\ChildDirectory1\\ChildDirectory2", this.folder.CombineToPhysicalPath("ChildDirectory1", "ChildDirectory2"));

            Assert.AreEqual(this.folderRoot.RootPhysicalPath + "\\ChildDirectory1\\ChildDirectory2", this.folder.CombineToPhysicalPath("/ChildDirectory1", "ChildDirectory2"));

            Assert.AreEqual(this.folderRoot.RootPhysicalPath + "\\ChildDirectory1\\ChildDirectory1\\ChildDirectory2", this.folder.CombineToPhysicalPath("ChildDirectory1", "ChildDirectory1/ChildDirectory2"));

            Assert.AreEqual(this.folderRoot.RootPhysicalPath + "\\ChildDirectory1\\ChildDirectory2", this.folder.CombineToPhysicalPath("ChildDirectory1", "/ChildDirectory1/ChildDirectory2"));
        }

        [TestMethod]
        [DeploymentItem("Core/FileSystems/MockFiles", "Directory1/MockFiles")]
        public void CombineToAppPath()
        {
            Assert.AreEqual(this.folderRoot.RootPath, this.folder.CombineToAppPath(""));

            Assert.AreEqual(this.folderRoot.RootPath + "/ChildDirectory1", this.folder.CombineToAppPath("ChildDirectory1"));

            Assert.AreEqual(this.folderRoot.RootPath + "/ChildDirectory1", this.folder.CombineToAppPath("/ChildDirectory1"));

            Assert.AreEqual(this.folderRoot.RootPath + "/ChildDirectory1/ChildDirectory2", this.folder.CombineToAppPath("ChildDirectory1", "ChildDirectory2"));

            Assert.AreEqual(this.folderRoot.RootPath + "/ChildDirectory1/ChildDirectory2", this.folder.CombineToAppPath("/ChildDirectory1", "ChildDirectory2"));

            Assert.AreEqual(this.folderRoot.RootPath + "/ChildDirectory1/ChildDirectory1/ChildDirectory2", this.folder.CombineToAppPath("ChildDirectory1", "ChildDirectory1/ChildDirectory2"));

            Assert.AreEqual(this.folderRoot.RootPath + "/ChildDirectory1/ChildDirectory2", this.folder.CombineToAppPath("ChildDirectory1", "/ChildDirectory1/ChildDirectory2"));
        }
    }
}
